Skip to content

Conversation

@miaulalala
Copy link
Contributor

@miaulalala miaulalala commented Dec 2, 2025

RFC: extending the Entity class to support snowflake IDs automagically

Good ides - yes / no?

Benefits:

  • every entity that supports snowflake IDs can automagically handle them by implementing the SnowflakeAwareEntity instead of the regular Entity
  • No adding IGenerator / IDecoder in every entity class
  • centralised method support for createdAt, setId, and anything else we would like to offer separately
  • get entire decoded snowflake id from the entity

Drawbacks:

  • Will it work the way I think it should?
  • Resolves: #

TODO

  • ...

Checklist

@miaulalala miaulalala added this to the Nextcloud 33 milestone Dec 2, 2025
@miaulalala miaulalala self-assigned this Dec 2, 2025
@miaulalala miaulalala requested a review from a team as a code owner December 2, 2025 13:10
@miaulalala miaulalala requested review from ArtificialOwl and icewind1991 and removed request for a team December 2, 2025 13:10
Copy link
Member

@CarlSchwan CarlSchwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Llike the Id :)

@come-nc
Copy link
Contributor

come-nc commented Dec 2, 2025

We should rename IGenerator and IDecoder to ISnowflakeGenerator and ISnowflakeDecoder, otherwise after a use all code is ambiguous.
A value object for decoded snowflakes would be good as well.

@miaulalala
Copy link
Contributor Author

We should rename IGenerator and IDecoder to ISnowflakeGenerator and ISnowflakeDecoder, otherwise after a use all code is ambiguous. A value object for decoded snowflakes would be good as well.

Added

Copy link
Collaborator

@Altahrim Altahrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we introduce a Snowflake DTO, I think Decoder should return it directly

@miaulalala
Copy link
Contributor Author

Would it make sense to cache the decoded snowflake ID? Seems like there's quite a few expensive calculations going on.

@Altahrim
Copy link
Collaborator

Altahrim commented Dec 4, 2025

We can still add a cache later if needed but decoding on 64 bits mainly involve binary operations, it should be fast.
32 bit is more complicated 😓

@miaulalala miaulalala requested a review from Altahrim December 4, 2025 13:51
@miaulalala miaulalala added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Dec 16, 2025
Copy link
Collaborator

@Altahrim Altahrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With same comment than Côme :)

Copy link
Member

@provokateurin provokateurin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small changes would be nice. Also I would prefer if the changes were done in multiple commits. I also noticed the name of the DI variable is inconsistent, maybe you can fix that as well.

miaulalala added a commit to nextcloud/spreed that referenced this pull request Dec 18, 2025
- [ ] needs nextcloud/server#56795
- [ ] needs #16508

Skipping CI for now, amend the commit message and remove the skip-ci param when ready to rebase and merge

[skip-ci]

Signed-off-by: Anna Larch <[email protected]>
@miaulalala miaulalala force-pushed the feat/noid/extend-entity-to-be-snoflake-aware branch from 75a21de to 8d35e95 Compare December 18, 2025 22:34
miaulalala added a commit to nextcloud/spreed that referenced this pull request Dec 18, 2025
- [ ] needs nextcloud/server#56795
- [ ] needs #16508

Skipping CI for now, amend the commit message and remove the skip-ci param when ready to rebase and merge

[skip ci]

Signed-off-by: Anna Larch <[email protected]>
@miaulalala miaulalala force-pushed the feat/noid/extend-entity-to-be-snoflake-aware branch from ba2f797 to 67b168a Compare December 23, 2025 08:49
@CarlSchwan CarlSchwan force-pushed the feat/noid/extend-entity-to-be-snoflake-aware branch 3 times, most recently from 29d972b to 4238c1e Compare January 6, 2026 09:16
miaulalala and others added 4 commits January 6, 2026 12:57
And introduce the Snowflake DTO

Signed-off-by: Anna Larch <[email protected]>
- Rename setId() -> generateId() in SnowflakeAwareEntity

Signed-off-by: Carl Schwan <[email protected]>
@CarlSchwan CarlSchwan force-pushed the feat/noid/extend-entity-to-be-snoflake-aware branch from 4238c1e to 7c1a8a4 Compare January 6, 2026 11:57
@CarlSchwan CarlSchwan marked this pull request as draft January 6, 2026 14:16
Otherwise this breaks some existing code, in particular PublicKeyToken

Signed-off-by: Carl Schwan <[email protected]>
@CarlSchwan CarlSchwan marked this pull request as ready for review January 6, 2026 14:43
@nextcloud-bot nextcloud-bot mentioned this pull request Jan 7, 2026
CarlSchwan pushed a commit to nextcloud/spreed that referenced this pull request Jan 7, 2026
- [ ] needs nextcloud/server#56795
- [x] needs #16508

Skipping CI for now, amend the commit message and remove the skip-ci param when ready to rebase and merge

[skip ci]

Signed-off-by: Anna Larch <[email protected]>
Signed-off-by: Carl Schwan <[email protected]>
@nickvergessen nickvergessen merged commit 40b79f5 into master Jan 7, 2026
208 of 220 checks passed
@nickvergessen nickvergessen deleted the feat/noid/extend-entity-to-be-snoflake-aware branch January 7, 2026 12:42
CarlSchwan pushed a commit to nextcloud/spreed that referenced this pull request Jan 7, 2026
- [x] needs nextcloud/server#56795
- [x] needs #16508

Signed-off-by: Anna Larch <[email protected]>
Signed-off-by: Carl Schwan <[email protected]>
/** @var int $id */
public $id = null;

public int|string|null $id = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miaulalala @CarlSchwan Is this really needed? This is breaking, as now any code accessing this property need to adapt to support all of those types.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were some more last polishing PRs around the time of your comment, can you check latest ocp package?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The typing is still the same on latest master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants